<template>
  <span :class="className">{{ text }}</span>
</template>

<script>
export default {
  name: "dosageForm",
  props: {
    pstType: {
      type: Number,
      default: 0
    },
    dosageForm: {
      type: Number,
      default: 0
    },
    background: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    text() {
      // 处方类型1-饮片，2-颗粒，3-打粉, 4-制丸, 5-膏方
      // 处方剂型 如果是饮片，1-自煎，2-代煎；如果是颗粒剂，传 1； 如果是打粉，1-细粉，2-粗粉； 
      // 如果是制丸，1-水丸，2-蜜丸，3-大 蜜丸，4-浓缩丸，5-水蜜丸； 如果是膏方，1-瓶装，2-袋装，3-块 装
      let { dosageForm, pstType, text1, text2 } = this;
      let res = "";
      switch(pstType) {
        case 1:
          res = dosageForm == 1 ? "自煎":"代煎";
          break;
        case 2:
          res = "颗粒";
          break;
        case 3:
          res = dosageForm == 1 ? "细粉":"粗粉";
          break;
        case 4:
          res = text1[dosageForm - 1];
          break;
        case 5:
          res = text2[dosageForm - 1];
          break;
      }
      return res;
    },
    className() {
      let text = this.text;
      let res = "dosage-status ";
      if(!text || !this.background) return "";
      if(text === "自煎") {
        res += "status-2";
      } else {
        res += "status-1";
      }
      return res;
    }
  },
  data() {
    return {
      text1: ["水丸","蜜丸","大蜜丸","浓缩丸","水蜜丸"],
      text2: ["瓶装","袋装","块装"]
    };
  }
}

</script>